import java.util.Arrays;
import java.util.Scanner;

public class 移动距离 {
    static int k=0;
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        int max = Math.max(a,b);
        int[][] arr = new int[(max/n)+1][n];
        int[] tmp = new int[4];
        boolean bo = true;
        int f=0;
        for (int i = 0; i <((max/n)+1) ; i++) {
            if(bo) {
                for (int j = 0; j < n; j++)  {
                    arr[i][j] = ++k;
                    if(arr[i][j]==a||arr[i][j]==b) {
                        tmp[f++]=i;
                        tmp[f++]=j;
                    }
                }
                bo = false;
            }else {
                for (int j = n-1; j >=0; j--)  {
                    arr[i][j] = ++k;
                    if(arr[i][j]==a || arr[i][j]==b) {
                        tmp[f++]=i;
                        tmp[f++]=j;
                    }
                }
                bo = true;
            }
        }
         int end = Math.abs(tmp[0]-tmp[2])+Math.abs(tmp[1]-tmp[3]);
        System.out.println(end);


    }
}
